﻿Imports System.Data
Imports System.Data.OleDb

Partial Class ContestDetails
    Inherits System.Web.UI.Page

    Protected Sub btnVote_Click(sender As Object, e As System.EventArgs) Handles btnVote.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "Insert into tblVotes(Vote,ContestID) Values (@f1,@f2)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", RBVote.SelectedValue)
        cmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("VotingConfirmation.aspx")
    End Sub

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If IsPostBack = False Then
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
            oleDbConn.Open()
            Dim ArtViewSql As String = "INSERT INTO tblContestViewed(Neighbor, Contest) VALUES(@f1,@f2)"
            Dim cmd As OleDbCommand = New OleDbCommand(ArtViewSql, oleDbConn)
            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
            cmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
            cmd.ExecuteNonQuery()
        End If
    End Sub
End Class
